home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-02 | 682 b | 26 lines | [TEXT/MPad] |
- -- Show additive waveform synthesis.
- -- Requires XFuns "sliders" and "playsynth"
-
- -- Create a signal by adding n sine waves.
- -- Each has a different frequency f and amplitude c[f]
- n=4
- sig(t) = sum(c[f]*sin(2*π*f*t),f,1,n)
-
- -- use a slider bar to set each amplitude
- sliders[i] = slider(i,0,1) dim[n]
- c:= sliders:;
- label c:{0.50,0.50,0.50,0.50}
- Xmin=0; Xmax=1; Ymin=-2; Ymax=2
- plot sig(X)
-
- -- slider values of {1, 0, .15, 0} approximate a square wave, {1, .3, .06, .02} for sawtooth
-
- -- sample sig(t) for the sound synthesizer
- samp[i] = sig((i-1)/511) dim[512]
-
- note := slider("note",50,100):
- amp := slider("volume",0,1):
-
- (loadsynth(samp),
- playsynth(note,2,amp)) when amp>0:
-